import { Component,_decorator } from "cc";
import { Logger } from "./log/Logger";
import AudioManager from "./manager/AudioManager";
import { ConfigManager } from "./manager/ConfigManager";
import { LoaderBundle } from "./manager/LoaderBundle";
import { LoaderManager } from "./manager/LoaderManager";
import { Message } from "./manager/Message";
import { Singleton } from "./manager/Singleton";
import { SingletonComponent } from "./manager/SingletonComponent";
import { UILayerIndex, UIManager, UIWindowMessage } from "./manager/UIManager";
import { HttpManager } from "./net/HttpManager";
import { I18Manager } from "./manager/I18Manager";
import { TimeTools } from "./tools/TimeTools";
import GameUtils from "./tools/GameUtils";
import { Network } from "./net/Network";
import { SystemParams } from "./manager/SystemParams";
import { ObjectPool } from "./manager/ObjectPool";
const { ccclass } = _decorator;
 
@ccclass('Adaptation')
export class Adaptation extends Component{
    private adapt_list:any=[
        //日志
        {name:"Logger",cls:Logger,isInit:true}, 
        //tools
        {name:"TimeTools",cls:TimeTools,isInit:false}, 
        {name:"GameUtils",cls:GameUtils,isInit:false}, 
        
        //managers
        {name:"Singleton",cls:Singleton,isInit:false},
        {name:"SingletonComponent",cls:SingletonComponent,isInit:false},

        {name:"AudioManager",cls:AudioManager,isInit:true},
        {name:"ConfigManager",cls:ConfigManager,isInit:true},
        {name:"LoaderBundle",cls:LoaderBundle,isInit:true},
        {name:"LoaderManager",cls:LoaderManager,isInit:true},
        {name:"Message",cls:Message,isInit:true}, 
        {name:"UILayerIndex",cls:UILayerIndex,isInit:true},
        {name:"UIWindowMessage",cls:UIWindowMessage,isInit:true},
        {name:"UIManager",cls:UIManager,isInit:true},
        {name:"I18Manager",cls:I18Manager,isInit:true},
        {name:"SystemParams",cls:SystemParams,isInit:true},
        {name:"ObjectPool",cls:ObjectPool,isInit:true},
        
        
        //网络
        {name:"HttpManager",cls:HttpManager,isInit:true}, 
        {name:"Network",cls:Network,isInit:true}, 

    ]
    protected __preload(): void {
        for(var key in this.adapt_list){  
            const item_cls:any=this.adapt_list[key]
            if(item_cls){ 
                window[item_cls.name]=item_cls.cls 
                if(item_cls.cls.getInstance && item_cls.isInit)item_cls.cls.getInstance();  
            } 
        } 
        //初始化完SDK后，将显示对象从显示列表中移除
        this.node.destroy()
    }

}